<?php
class LoginAction extends Action {
	
	public function index(){
		
	$this->display();
	}
	
	public function login(){
		if (!IS_POST) halt("页面不存在!");
		$username = I('username');
		$passwd = I('passwd','','md5');
		$user = M('admin')->where(array('username' => $username))->find();
		if (!$user || $user['passwd'] != $passwd) {
			$this->error('用户名或密码错误!');
		}else{
			session('uid',$user['id']);
			session('username',$user['username']);
			$this-redirect('../Index/index');
		}
		
		
	}
	
} 